from rest_framework import serializers
from department import models



class DepartmentSerializer(serializers.ModelSerializer):
  # cate = DepartmentCateSerializer(read_only=True)
  # catename = serializers.SerializerMethodField(read_only=True)
  # def get_catename(self,obj):
  #     return obj.cate.name
  # cates = serializers.CharField(source='cates.name',read_only=True)
  class Meta:
    model = models.DepartmentModel
    fields = '__all__'


class DepartmentCateSerializer(serializers.ModelSerializer):
    cates = DepartmentSerializer(read_only=True,many=True)
    class Meta:
        model = models.DepartmentCateModel
        fields = '__all__'





